#pragma once
#include"TCP_Socket.hpp"

class TCPClient
{
public:
    TCPClient(const std::string& ip,uint16_t port)
        :ip_(ip)
        ,port_(port)
    {
        //先创建好socket
        sock_.Socket();
    }

    ~TCPClient()
    {
        sock_.Close();
    }

    bool Connect()
    {
        return sock_.Connect(ip_,port_);
    }

    bool Recv(std::string* buf)
    {
        return sock_.Recv(buf);
    }
    
    bool Send(const std::string& buf)
    {
        return sock_.Send(buf);
    }
private:
    TCPSocket sock_;
    std::string ip_;
    uint16_t port_;
};